﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{

    public class LASTEKPRData : BaseFunction
    {
        
        public LASTEKPRData()
            : base()
        {
           
        }
        public LASTEKPRData(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {
        }
        public DataSet GetRawData(DataRow dwABPOS)
        {
            DataSet set4Return = new DataSet();
            DataSet setLocal = new DataSet();
            DataSet setResult = new DataSet();
            DataSet setTemp = new DataSet();
            DataTable tableLocal = null;
            string ARTICLE,FDATE,EDATE;
            ARTICLE = dwABPOS["ARTICLE"].ToString().Trim();
            try
            {
                OracleCommand or1 = OracleDB.CreateCommand();
          
                #region
                or1.CommandText = " select a.EKPART,a.EKPVAR,a.EKPFARBE, a.price, a.lastdat "
                    + " from last_ek_pr a " 
                    + " where a.ekpart LIKE '" + ARTICLE + "%'  "                    
                    ;

                #endregion
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "LASTEKPR";
                   
                }
                set4Return.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return set4Return;
        }
        
        public DataSet BuildEKPR(DataRow dwUI)
        {
            string progress = "查询完成";
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            try
            {
                EventDispatcher.Instance.RaiseStatus("查询开始", StatusEventType.StartProgress);
                setResult = GetRawData(dwUI);
                setReturn.Merge(setResult);
                EventDispatcher.Instance.RaiseStatus("查询完成", StatusEventType.StopProgress);
            }
            catch (Exception ex)
            {
                Tracer.Error(ABPOS + ex.StackTrace, ex);
            }
            return setReturn;
        }
    }
}